import React from 'react';
import { Row, Col, Button, message, Form, Popconfirm, Upload, Icon, Table, Input, Select } from 'antd';
const R = require('ramda');
import { connect } from 'dva';
import BizParams from '../../../components/commons/BizParams';
import ChooseProduct from '../components/ChooseProduct';
import dateFormat from 'dateformat';
import { download } from '../../../utils/commons'
import Constants from '../../../utils/Constants'
import RightBox from "../../commons/RightBox";
import RIGHT from "../../../utils/RightConstants";

const FormItem = Form.Item;
export default connect(({ app }) => ({ app }))(Form.create({ wrappedComponentRef: true })(class ImportCD extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            failReson: false
        }
    }

    componentDidMount() {
        this.props.dispatch({
            type: 'app/getAllCurrencys' //确保币种在该页面能从localstore拿到
        });
    }

    handleResetFields = () => {
        this.props.form.resetFields();
    }

    handleChangeApprovalResult = (value) => {
        this.props.form.resetFields(["gobackreason"]);
        this.setState({ failReson: value === "1" });
    }

    handleSubmitApproval = () => {
        let flag = true;
        if (this.props.form.getFieldValue("approvalResult") === "0") { //通关受理
            this.props.form.validateFieldsAndScroll((errors, values) => {
                if (R.isNil(values.transporttype) || R.isEmpty(values.transporttype)) {
                    message.error("请选择运输方式!");
                    flag = false;
                    return;
                }

                if (flag) {
                    let approvalSource = R.omit(['approvalResult', 'gobackreason'])(values);
                    approvalSource.orderid = R.isNil(this.props.dataSource) || R.isNil(this.props.dataSource.id) ? "" : this.props.dataSource.id;

                    this.props.dispatch({
                        type: 'declareApproval/approvalOrder',
                        payload: {
                            searchConditions: this.props.searchConditions,
                            approvalSource: approvalSource
                        }
                    });
                }
            })
        } else {
            this.props.form.validateFieldsAndScroll((errors, values) => {
                if (errors) { flag = false; return }
                if (R.isNil(values.gobackreason) || R.isEmpty(values.gobackreason)) {
                    this.props.form.setFields({
                        gobackreason: {
                            errors: [new Error('请输入退回原因')],
                            value: undefined
                        }
                    })
                    flag = false;
                    return;
                }
                if (flag) {
                    this.props.dispatch({
                        type: 'declareApproval/returnOrder',
                        payload: {
                            id: R.isNil(this.props.dataSource) || R.isNil(this.props.dataSource.id) ? "" : this.props.dataSource.id,
                            searchConditions: this.props.searchConditions,
                            gobackreason: values.gobackreason,
                        }
                    });
                }
            })
        }
        if (flag && this.props.handleCancel) {
            this.props.handleCancel(["5"]);
        }
    }

    handleGeneateCD = (tgyFlag) => {
        this.props.form.validateFieldsAndScroll((errors, values) => {
            if (errors) return;
            let orderId = R.isNil(this.props.dataSource) || R.isNil(this.props.dataSource.id) ? "" : this.props.dataSource.id;
            let url = apiPath.zbtie + "/api/order/" + orderId + "/generateDeclareInfo";
            let conditions = {
                id: R.isNil(this.props.orderTgApproval) || R.isNil(this.props.orderTgApproval.id) ? "" : this.props.orderTgApproval.id,
                status: this.props.dataSource ? this.props.dataSource.status : null,
                relationshipconfirm: values.relationshipconfirm,
                priceconfirm: values.priceconfirm,
                paycostconfirm: values.paycostconfirm,
                selfpayconfirm: values.selfpayconfirm,
                tgyFlag
            }
            if(!tgyFlag) {
                download(url, conditions);
                if (this.props.handleCancel) this.props.handleCancel(["5"]);
            }
            else {
                this.props.dispatch({
                    type: 'declareApproval/geneateCD',
                    payload: {
                        orderId,
                        ...conditions,
                        onSuccess: () => {
                            if (this.props.handleCancel) this.props.handleCancel(["5"]);
                            if (this.props.refreshList) this.props.refreshList(false)
                        }
                    }
                });
            }
        })
    }

    initColumns = () => {
        let key = 1;
        let dataSource = R.isNil(this.props.dataSource) ? {} : this.props.dataSource;
        let currencys = R.isNil(sessionStorage.getItem(Constants.preCurrency)) ? [] : JSON.parse(sessionStorage.getItem(Constants.preCurrency));
        let currencyCode = "";
        let currencyName = "";
        let freightCurrencyCode = ""
        let premiumCurrencyCode = ""
        R.map((currency) => {
            if (dataSource.currencytype === currency.currencyName) { currencyCode = currency.currencyCode; currencyName = currency.currencyDesc }
            if (dataSource.freightcurrency === currency.currencyName) freightCurrencyCode = currency.currencyCode;
            if (dataSource.premiumcurrency === currency.currencyName) premiumCurrencyCode = currency.currencyCode;
        }, currencys);
        let columns = [
            {
                title: '项号', dataIndex: 'index', key: 'index',
                render: (value, row, index) => {
                    return key++;
                }
            },
            { title: '商品编号', dataIndex: 'producthscode', key: 'producthscode' },
            {
                title: '商品名称及规格型号', dataIndex: 'productname', key: 'productname',
                render: (value, row, index) => {
                    let branch = row.productbranch;
                    //productbranchname => productbranchtype的转义
                    if (!R.isNil(row.productbranchtype) && !R.isEmpty(row.productbranchtype)) {
                        if (row.productbranchtype === '1') {
                            branch = row.productbranchname;
                        } else {
                            branch = row.productbranchname + "|" + branch
                        }
                    }
                    return (
                        <div>
                            <div>{row.productname}</div>
                            <div>{branch}|{row.productmodel}|{row.productdeclarelements}|{row.productsize}</div>
                        </div>
                    )
                }
            },
            {
                title: '数量及单位', dataIndex: 'productnumber', key: 'productnumber',
                render: (value, row, index) => {
                    return (
                        <div>{row.productnumber}{row.productunit}</div>
                    )
                }
            },
            {
                title: '单价/总价/币制', key: 'amt', render: (value, row, index) => {
                    return (<div>
                        <div>{row.productprice}</div>{row.totalprice}<div>{currencyName}</div>
                    </div>)
                }
            },
            {
                title: '原产国(地区)', key: 'originCountry', render: () => {
                    return <div>中国(CHN)</div>
                }
            },
            {
                title: '最终目的国(地区)', dataIndex: 'country', key: 'country',
                render: (value, row, index) => {
                    let dataSource = R.isNil(this.props.dataSource) ? {} : this.props.dataSource;
                    return (
                        <div>
                            <div>{R.isNil(this.props.countryCD.sprValue) ? "" : this.props.countryCD.sprValue}({R.isNil(dataSource.countrycd) ? "" : dataSource.countrycd})</div>
                        </div>
                    )
                }
            },
            {
                title: '境内货源地', key: 'supplyGood', render: (value, row, index) => {
                    if(this.props.customer.businessType === '2') return <div>{dataSource.domesticSupply}</div>
                    else return <div>({row.supplyGoodCode}){row.supplyGoodValue}</div>
                }
            },
            {
                title: '征免', dataIndex: 'natureExemption', key: 'natureExemption',
                render: (value, row, index) => {
                    return (
                        <div>{R.isNil(this.props.natureExemption.sprValue) ? "" : this.props.natureExemption.sprValue}</div>
                    )
                }
            }]
        return columns;
    }


    render() {
        let lesseeInfo = R.isNil(this.props.lesseeInfo) ? {} : this.props.lesseeInfo;
        let dataSource = R.isNil(this.props.dataSource) ? {} : this.props.dataSource;
        let declaration = this.props.declaration ? this.props.declaration : {};//市场采购报关抬头信息
        let editDisabled = this.props.disabled || dataSource.status !== "2";
        let generateDisabled = this.props.disabled || dataSource.status !== "5";
        let productList = R.isNil(dataSource.orderProductDetails) ? [] : dataSource.orderProductDetails;
        let totleamount = R.isNil(dataSource.totleamount) ? 0 : Math.round(dataSource.totleamount * 100) / 100;
        let supplyGoods = ""
        R.map((row) => { if (row.sprName === dataSource.supplygoods) supplyGoods = row.sprValue }, R.isNil(this.props.supplyGoodsList) ? [] : this.props.supplyGoodsList)
        const { getFieldDecorator } = this.props.form;
        let orderTgApproval = R.isNil(this.props.orderTgApproval) ? {} : this.props.orderTgApproval;
        let formItemLayout = {
            labelCol: { xs: { span: 24 }, sm: { span: 6 } },
            wrapperCol: { xs: { span: 24 }, sm: { span: 14 } }
        };
        let formItemLayout1 = {
            labelCol: { xs: { span: 24 }, sm: { span: 11 } },
            wrapperCol: { xs: { span: 24 }, sm: { span: 4 } }
        };
        let formItemLayout2 = {
            labelCol: { xs: { span: 24 }, sm: { span: 9 } },
            wrapperCol: { xs: { span: 24 }, sm: { span: 14 } }
        };

        let customer = this.props.customer ? this.props.customer : {};

        let provider = '' //境内发货人
        let providerCode = '';//境内发货人编码
        let seller = '' //生产销售单位
        let sellerCode = ''//生产销售编码

        
        if(customer.businessType === "2"){//市场采购,都取报关抬头的信息
            provider = declaration.name;
            providerCode = `(${declaration.tin})`;
            seller = provider;
            sellerCode = providerCode;
        }else{//会员客户的生产销售单位跟境内发货人都要是客户名称
            if(customer.csttype === '2'){
                provider = customer.companyname ? customer.companyname : '';
                providerCode = customer.taxpayerid ? "(" + customer.taxpayerid + ")" : "";
                seller = provider;
                sellerCode = providerCode;
            }else{
                //非会员客户(正常客户)
                provider = lesseeInfo.lesseeNameCn ? lesseeInfo.lesseeNameCn : '';
                providerCode = lesseeInfo.taxpayerCode ? "(" + lesseeInfo.taxpayerCode + ")" : "";
                if(dataSource.declarationstyle === '2'){ //客户抬头
                    seller = customer.companyname ? customer.companyname : '';
                    sellerCode = customer.taxpayerid ? "(" + customer.taxpayerid + ")" : "";
                }else{
                    seller = provider;
                    sellerCode = providerCode;
                }
            }
        }
        const divWithOutBorderBottom = {
            display: 'flex',
            borderRight: '1px solid #e9e9e9',
            borderLeft: '1px solid #e9e9e9',
            borderTop: '1px solid #e9e9e9',
            borderSpacing: 0,
            lineHeight: 2,
            textAlign: 'center',
        }

        let freightCurrencyCode = ""
        let premiumCurrencyCode = ""
        let currencys = R.isNil(sessionStorage.getItem(Constants.preCurrency)) ? [] : JSON.parse(sessionStorage.getItem(Constants.preCurrency));
        R.map((currency) => {
            if (dataSource.freightcurrency === currency.currencyName) freightCurrencyCode = currency.currencyCode;
            if (dataSource.premiumcurrency === currency.currencyName) premiumCurrencyCode = currency.currencyCode;
        }, currencys);

        let packtypeelse = dataSource.kindpackage && dataSource.kindpackage.split('|').includes('99') && dataSource.packtypeelse ? ("其它包装: " + dataSource.packtypeelse + ",  ") : "";

        return (
            <div>
                <div style={{ textAlign: 'center' }}>
                    <span><b><font size="4">中华人民共和国海关出口货物报关单</font></b></span>
                    <div style={{ lineHeight: 2 }}>
                        <span style={{ float: 'left' }}>预录入编号:</span>
                        <span>海关编号:</span>
                        <span style={{ float: 'right' }}>页码/页数:</span>
                    </div>
                </div>
                <div style={Object.assign({}, { marginTop: 10, borderRadius: '4px 4px 0 0' }, divWithOutBorderBottom)}>
                    <div style={{ width: '30%', borderRight: '1px solid #e9e9e9' }}>
                        <div>境内发货人{providerCode}</div>
                        <div>{provider}</div>
                    </div>
                    <div style={{ width: '15%', borderRight: '1px solid #e9e9e9' }}>
                        <div>出境关别({R.isNil(dataSource.portofentryid) ? "" : dataSource.portofentryid})</div>
                        <div>{R.isNil(this.props.placeClearance) || R.isNil(this.props.placeClearance.placeName) ? "" : this.props.placeClearance.placeName}</div>
                    </div>
                    <div style={{ width: '15%', borderRight: '1px solid #e9e9e9' }}>
                        <div>出口日期</div>
                        <div></div>
                    </div>
                    <div style={{ width: '20%', borderRight: '1px solid #e9e9e9' }}>
                        <div>申报日期</div>
                        <div></div>
                    </div>
                    <div style={{ width: '20%' }}>
                        <div>备案号</div>
                        <div></div>
                    </div>
                </div>
                <div style={divWithOutBorderBottom}>
                    <div style={{ width: '30%', borderRight: '1px solid #e9e9e9' }}>
                        <div>境外收货人{dataSource.consigneeCode ? "(" + dataSource.consigneeCode + ")" : ""}</div>
                        <div>{dataSource.consignee ? dataSource.consignee : ""}</div>
                    </div>
                    <div style={{ width: '15%', borderRight: '1px solid #e9e9e9' }}>
                        <div>运输方式</div>
                        <span>
                            {getFieldDecorator('transporttype', {
                                initialValue: R.isNil(dataSource.transporttype) ? undefined : dataSource.transporttype
                            })(
                                <BizParams sprCode='transportType' disabled={editDisabled} style={{ width: '90%', marginBottom: 5 }} />
                                )}
                        </span>
                    </div>
                    <div style={{ width: '15%', borderRight: '1px solid #e9e9e9' }}>
                        <div>运输工具名称及航次号</div>
                        <div></div>
                    </div>
                    <div style={{ width: '40%' }}>
                        <div>提运单号</div>
                        <div></div>
                    </div>
                </div>
                <div style={divWithOutBorderBottom}>
                    <div style={{ width: '30%', borderRight: '1px solid #e9e9e9' }}>
                        <div>生产销售单位{sellerCode}</div>
                        <div>{seller}</div>
                    </div>
                    <div style={{ width: '15%', borderRight: '1px solid #e9e9e9' }}>
                        <div>监管方式({R.isNil(dataSource.supervision) ? "" : dataSource.supervision})</div>
                        <div>{R.isNil(this.props.supervision.sprValue) ? "" : this.props.supervision.sprValue}</div>
                    </div>
                    <div style={{ width: '15%', borderRight: '1px solid #e9e9e9' }}>
                        <div>征免性质({R.isNil(dataSource.natureexemption) ? "" : dataSource.natureexemption})</div>
                        <div>{R.isNil(this.props.natureExemption.sprValue) ? "" : this.props.natureExemption.sprValue}</div>
                    </div>
                    <div style={{ width: '40%' }}>
                        <div>许可证号</div>
                        <div></div>
                    </div>
                </div>
                <div style={divWithOutBorderBottom}>
                    <div style={{ width: '30%', borderRight: '1px solid #e9e9e9' }}>
                        <div>合同协议号</div>
                        <div>{R.isNil(dataSource.contractno) ? "" : dataSource.contractno}</div>
                    </div>
                    <div style={{ width: '15%', borderRight: '1px solid #e9e9e9' }}>
                        <div>贸易国(地区)({R.isNil(dataSource.tradecountry) ? "" : dataSource.tradecountry})</div>
                        <div>{R.isNil(this.props.tradeCountry.sprValue) ? "" : this.props.tradeCountry.sprValue}</div>
                    </div>
                    <div style={{ width: '15%', borderRight: '1px solid #e9e9e9' }}>
                        <div>运抵国(地区)({R.isNil(dataSource.countrycd) ? "" : dataSource.countrycd})</div>
                        <div>{R.isNil(this.props.countryCD.sprValue) ? "" : this.props.countryCD.sprValue}</div>
                    </div>
                    <div style={{ width: '20%', borderRight: '1px solid #e9e9e9' }}>
                        <div>指运港</div>
                        <div>
                            {getFieldDecorator('portofdest', {
                                initialValue: dataSource.portofdest
                            })(
                                <BizParams disabled={true} sprCode='portOfDest' style={{ width: '90%', marginBottom: 5 }} />
                                )}
                        </div>
                    </div>
                    <div style={{ width: '20%' }}>
                        <div>离境口岸</div>
                        <div></div>
                    </div>
                </div>
                <div style={divWithOutBorderBottom}>
                    <div style={{ width: '30%', borderRight: '1px solid #e9e9e9' }}>
                        <div>包装种类({R.isNil(dataSource.kindpackage) ? "" : dataSource.kindpackage})</div>
                        <div>{R.isNil(this.props.kindPackage) ? "" : this.props.kindPackage + ""}</div>
                    </div>
                    <div style={{ width: '7%', borderRight: '1px solid #e9e9e9' }}>
                        <div>件数</div>
                        <div>{R.isNil(dataSource.maxpacknum) ? 0 : dataSource.maxpacknum}</div>
                    </div>
                    <div style={{ width: '8%', borderRight: '1px solid #e9e9e9' }}>
                        <div>毛重(千克)</div>
                        <div>{R.isNil(dataSource.totalgross) ? 0 : dataSource.totalgross}</div>
                    </div>
                    <div style={{ width: '7%', borderRight: '1px solid #e9e9e9' }}>
                        <div>净重(千克)</div>
                        <div>{R.isNil(dataSource.totalweight) ? 0 : dataSource.totalweight}</div>
                    </div>
                    <div style={{ width: '8%', borderRight: '1px solid #e9e9e9' }}>
                        <div>成交方式({R.isNil(dataSource.priceclause) ? "" : dataSource.priceclause})</div>
                        <div>{R.isNil(this.props.priceItem.sprValue) ? "" : this.props.priceItem.sprValue}</div>
                    </div>
                    <div style={{ width: '13%', borderRight: '1px solid #e9e9e9' }}>
                        <div>运费</div>
                        <div>{R.isEmpty(freightCurrencyCode) ? "" : freightCurrencyCode + "/"}{R.isNil(dataSource.freight) ? "" : dataSource.freight}</div>
                    </div>
                    <div style={{ width: '13%', borderRight: '1px solid #e9e9e9' }}>
                        <div>保费</div>
                        <div>{R.isEmpty(premiumCurrencyCode) ? "" : premiumCurrencyCode + "/"}{R.isNil(dataSource.premium) ? "" : dataSource.premium}</div>
                    </div>
                    <div style={{ width: '14%' }}>
                        <div>杂费</div>
                        <div></div>
                    </div>
                </div>
                <div style={divWithOutBorderBottom}>
                    <div style={{ width: '30%', borderRight: '1px solid #e9e9e9' }}>
                        <div>集装箱号</div>
                        <span>
                            {getFieldDecorator('boxno', {
                                initialValue: dataSource.boxno
                            })(
                                <Input maxLength="1000" disabled={editDisabled} style={{ width: '80%', marginBottom: 5, textAlign: 'center' }} />
                                )}
                        </span>
                    </div>
                    <div style={{ width: '50%', borderRight: '1px solid #e9e9e9' }}>
                        <div>随附单证及编号</div>
                        <span>
                            {getFieldDecorator('attachedreceiptno', {
                                initialValue: orderTgApproval.attachedreceiptno
                            })(
                                <Input maxLength="100" disabled={editDisabled} style={{ width: '80%', marginBottom: 5, textAlign: 'center' }} />
                                )}
                        </span>
                    </div>
                    <div style={{ width: '20%' }}>
                        <div>生产厂家</div>
                        <div>{R.isNil(this.props.customer.companyname) ? "" : this.props.customer.companyname}</div>
                    </div>
                </div>
                <div style={divWithOutBorderBottom}>
                    <div style={{ width: '100%' }}>
                        <div>标记麦码及备注</div>
                        <span>
                            {getFieldDecorator('tgmemo', {
                                initialValue: dataSource.status === '2' ?  packtypeelse + dataSource.boxno : orderTgApproval.tgmemo
                            })(
                                <Input.TextArea disabled={editDisabled} maxLength="100" style={{ width: '80%', marginBottom: 5 }} autosize={true} />
                                )}
                        </span>
                    </div>
                </div>
                <Table dataSource={productList} columns={this.initColumns()} bordered={true} size={'middle'} pagination={false} scroll={{ x: true }} />
                {/* <div style={Object.assign({}, divWithOutBorderBottom, { borderTop: null })}>
                    <div style={{ width: '100%' }}>
                        <div>税费征收情况 </div>
                        <div style={{ float: 'right', marginRight: 10 }}>合计总价:{totleamount}</div>
                    </div>
                </div> */}
                <div style={Object.assign({}, divWithOutBorderBottom, { display: R.contains(dataSource.status, ["5", "6", "7"]) ? 'block' : 'none', borderTop: null })}>
                    <Row>
                        <Col span={6}>
                            <FormItem {...formItemLayout1} label="特殊关系确认" hasFeedback style={{ margin: '12px 0px' }}>
                                {getFieldDecorator('relationshipconfirm', {
                                    rules: [{
                                        required: true, message: '请选择特殊关系确认'
                                    }],
                                    initialValue: R.isNil(orderTgApproval.relationshipconfirm) || R.isEmpty(orderTgApproval.relationshipconfirm) ? "0" : orderTgApproval.relationshipconfirm
                                })(
                                    <Select style={{ width: '100%' }} disabled={generateDisabled}>
                                        <Select.Option value="1" key="1">是</Select.Option>
                                        <Select.Option value="0" key="0">否</Select.Option>
                                    </Select>
                                    )}
                            </FormItem>
                        </Col>
                        <Col span={6}>
                            <FormItem {...formItemLayout1} label="价格影响确认" hasFeedback style={{ margin: '12px 0px' }}>
                                {getFieldDecorator('priceconfirm', {
                                    rules: [{
                                        required: true, message: '请选择价格影响确认'
                                    }],
                                    initialValue: R.isNil(orderTgApproval.priceconfirm) || R.isEmpty(orderTgApproval.priceconfirm) ? "0" : orderTgApproval.priceconfirm
                                })(
                                    <Select style={{ width: '100%' }} disabled={generateDisabled}>
                                        <Select.Option value="1" key="1">是</Select.Option>
                                        <Select.Option value="0" key="0">否</Select.Option>
                                    </Select>
                                    )}
                            </FormItem>
                        </Col>
                        <Col span={6}>
                            <FormItem {...formItemLayout1} label="支付特许权使用费确认" hasFeedback style={{ margin: '12px 0px' }}>
                                {getFieldDecorator('paycostconfirm', {
                                    rules: [{
                                        required: true, message: '请选择支付特许权使用费确认'
                                    }],
                                    initialValue: R.isNil(orderTgApproval.paycostconfirm) || R.isEmpty(orderTgApproval.paycostconfirm) ? "0" : orderTgApproval.paycostconfirm
                                })(
                                    <Select style={{ width: '100%' }} disabled={generateDisabled}>
                                        <Select.Option value="1" key="1">是</Select.Option>
                                        <Select.Option value="0" key="0">否</Select.Option>
                                    </Select>
                                    )}
                            </FormItem>
                        </Col>
                        <Col span={6}>
                            <FormItem {...formItemLayout1} label="自报自缴" hasFeedback style={{ margin: '12px 0px' }}>
                                {getFieldDecorator('selfpayconfirm', {
                                    rules: [{
                                        required: true, message: '请选择自报自缴'
                                    }],
                                    initialValue: R.isNil(orderTgApproval.selfpayconfirm) || R.isEmpty(orderTgApproval.selfpayconfirm) ? "0" : orderTgApproval.selfpayconfirm
                                })(
                                    <Select style={{ width: '100%' }} disabled={generateDisabled}>
                                        <Select.Option value="1" key="1">是</Select.Option>
                                        <Select.Option value="0" key="0">否</Select.Option>
                                    </Select>
                                    )}
                            </FormItem>
                        </Col>
                    </Row>
                </div>
                <div style={Object.assign({}, divWithOutBorderBottom, { borderBottom: '1px solid #e9e9e9' })}>
                    <div style={{ width: '70%', borderRight: '1px solid #e9e9e9' }}>
                        <div style={{ textAlign: 'left', marginTop: 5 }}>
                            <span style={{ display: 'inline-block', padding: '0px 60px 10px 20px', verticalAlign: 'center' }}>
                                <span>报关人员</span>
                                <span style={{ marginLeft: 60 }}>报关人员证号</span>
                                <span style={{ marginLeft: 60 }}>电话</span>
                            </span>
                            <span style={{ marginRight: 20, float: 'right' }}>兹申明对以上内容承担如实申报、依法纳税之法律责任</span>
                        </div>
                        <div style={{ textAlign: 'left' }}>
                            <span style={{ display: 'inline-block', padding: '0px 60px 10px 20px', verticalAlign: 'center' }}>
                                <span>申报单位</span>
                            </span>
                            <span style={{ marginRight: 20, float: 'right' }}>申报单位(盖章)</span>
                        </div>
                    </div>
                    <div style={{ width: '40%', textAlign: 'left', marginLeft: 20 }}>
                        <div style={{ marginTop: 5 }}>海关审单批注及签章</div>
                    </div>
                </div>
                <div>
                    <Row style={{ marginTop: 20 }}>
                        <Col span={6} style={{ display: !editDisabled ? 'inline-block' : 'none' }}>
                            <FormItem {...formItemLayout2} label="审批结果" hasFeedback>
                                {getFieldDecorator('approvalResult', {
                                    rules: [{
                                        required: true, message: '请选择审批结果'
                                    }],
                                    initialValue: "0"
                                })(
                                    <Select style={{ width: '100%' }} onChange={this.handleChangeApprovalResult.bind(this)}>
                                        <Select.Option value="0" key="0">通关受理</Select.Option>
                                        <Select.Option value="1" key="1">订单退回</Select.Option>
                                    </Select>
                                    )}
                            </FormItem>
                        </Col>
                        <Col span={6} style={{ display: this.state.failReson && !editDisabled ? 'inline-block' : 'none' }}>
                            <FormItem {...formItemLayout} label="退回原因" hasFeedback>
                                {getFieldDecorator('gobackreason', {
                                    rules: [{
                                        required: this.state.failReason && !editDisabled, message: '请输入退回原因'
                                    }],
                                    initialValue: ""
                                })(
                                    <Input.TextArea maxLength="100" autosize={true} />
                                    )}
                            </FormItem>
                        </Col>
                        <Col span={6}>
                            <Button type="primary" icon="check" style={{ marginRight: 5, marginLeft: 0, display: editDisabled ? 'none' : 'inline-block' }} size={'default'} onClick={this.handleSubmitApproval.bind(this)}>提交</Button>
                        </Col>
                    </Row>
                    <iframe ref="ifile" style={{ display: 'none' }}></iframe>
                    <div style={{ marginLeft: '40%' }}>
                        <Button type="primary" icon="check" style={{ marginRight: 5, marginLeft: 0, display: generateDisabled ? 'none' : 'inline-block' }} size={'default'} onClick={this.handleGeneateCD.bind(this, false)}>生成报关资料</Button>
                        <RightBox resource={RIGHT.ORDER.ORDER_APPROVAL_TONGGUANYI}><Button type="primary" icon="check" style={{ marginRight: 5, marginLeft: 0, display: generateDisabled ? 'none' : 'inline-block' }} size={'default'} onClick={this.handleGeneateCD.bind(this, true)}>提交通关易</Button></RightBox>
                    </div>
                </div>
            </div>
        )
    }
}))